<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="" lay-filter="edit">
    <div class="mainBox">
        <div class="main-container">
            <!-- id隐藏列 -->
            <div class="layui-form-item layui-hide">
                <label class="layui-form-label">id</label>
                <div class="layui-input-block">
                    <input type="text" name="invId">
                </div>
                <label class="layui-form-label">商品ID</label>
                <div class="layui-input-block">
                    <input type="text" name="commId">
                </div>

                <label class="layui-form-label">商品规格ID</label>
                <div class="layui-input-block">
                    <input type="text" name="commSpecsId">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">商品类型</label>
                <div class="layui-input-block">
                    <input type="text" name="commTypeName" lay-verify="title|required" class="layui-input" readonly>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-input-block">
                    <input type="text" name="commName" lay-verify="title|required" class="layui-input" readonly>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">商品规格</label>
                <div class="layui-input-block">
                    <input type="text" name="commSpecsName" lay-verify="title|required" class="layui-input" readonly>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">入库日期</label>
                <div class="layui-input-block">
                    <input type="text" id="transDate" name="transDate" lay-verify="required|title" autocomplete="off"
                           placeholder="请输入入库日期"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">入库人员</label>
                <div class="layui-input-block">
                    <input type="text" name="invTradeinReceive" lay-verify="title" class="layui-input" maxlength="80"
                           placeholder="请输入入库人员">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">入库数量</label>
                <div class="layui-input-block">
                    <input type="text" name="transSum" lay-verify="number|required" autocomplete="off" maxlength="5"
                           placeholder="请输入入库数量"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入备注" name="transRemark" class="layui-textarea" autocomplete="off" maxlength="80" rows="9"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>

<script>
    layui.use(['form', 'jquery', 'dtree', 'laydate', 'easyAdmin'], function () {
        // let module = "message";
        // let uri = "/inv/" + module;
        // let easyAdmin = layui.easyAdmin;
        // easyAdmin.FormVal(uri);
        // easyAdmin.FormSave(uri);

        let form = layui.form;
        let $ = layui.jquery;
        let easyAdmin = layui.easyAdmin;
        let id;
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#transDate', //指定元素
            type: 'datetime'
        });

        form.on('submit(save)', function (data) {
            data.field.invId = id;

            easyAdmin.http({
                url: '/inv/message/tradein',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000, area: ['100px', '80px']}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000, area: ['260px', '80px']});
                    }
                }
            })
            return false;
        });

        id = easyAdmin.getQueryString("id");
        easyAdmin.http({
            url: '/inv/message/' + id,
            dataType: 'json',
            contentType: 'application/json',
            type: 'get',
            success: function (result) {
                if (result.success) {
                    //表单数据回显
                    form.val("edit", result.data);
                } else {
                    layer.msg(result.msg, {icon: 2, time: 1000});
                }
            }
        });
    })
</script>
<script>
</script>
</body>
</html>
